import { Controller, Post, Body, UseInterceptors } from '@nestjs/common';
import { IndexInterceptor } from '@libs/common/interceptors';
import { PayloadUser } from '@libs/common/decorator';
import { {{ pascalCase name }}Service } from './{{ kebabCase name }}.service';
import {
  Create{{ pascalCase name }}Dto,
  Index{{ pascalCase name }}Dto,
  Show{{ pascalCase name }}Dto,
  Update{{ pascalCase name }}Dto,
  Delete{{ pascalCase name }}Dto,
  Switch{{ pascalCase name }}Dto,
  Export{{ pascalCase name }}Dto,
  Import{{ pascalCase name }}Dto,
  Find{{ pascalCase name }}Dto,
} from './dto/{{ kebabCase name }}.dto';

@Controller('{{ kebabCase name }}')
export class {{ pascalCase name }}Controller {
  constructor(private readonly {{ camelCase name }}Service: {{ pascalCase name }}Service) {}

  @Post('index')
  @UseInterceptors(new IndexInterceptor())
  index(@Body() dto: Index{{ pascalCase name }}Dto) {
    return this.{{ camelCase name }}Service.index(dto);
  }

  @Post('show')
  show(@Body() dto: Show{{ pascalCase name }}Dto) {
    return this.{{ camelCase name }}Service.show(dto);
  }

  @Post('delete')
  delete(@Body() dto: Delete{{ pascalCase name }}Dto) {
    return this.{{ camelCase name }}Service.delete(dto);
  }

  @Post('create')
  create(@Body() dto: Create{{ pascalCase name }}Dto) {
    return this.{{ camelCase name }}Service.create(dto);
  }

  @Post('update')
  update(@Body() dto: Update{{ pascalCase name }}Dto, @PayloadUser() user: SC.User.SysInfo) {
    // user info 
    return this.{{ camelCase name }}Service.update(dto);
  }

  // 只返回一条对象数据，如果存在多个只返回第一条
  // @Post('findOne')
  // findOne(@Body() dto: FindAttendanceTodayDto) {
  //   return this.AttendanceTodayService.findOne(dto);
  // }

  // 返回所有符合条件的数据
  // @Post('find')
  // find(@Body() dto: FindAttendanceTodayDto) {
  //   return this.AttendanceTodayService.find(dto);
  // }

  // @Post('import')
  // import(@Body() dto: Export{{ pascalCase name }}Dto) {}

  // @Post('export')
  // export(@Body() dto: Import{{ pascalCase name }}Dto) {}

  // @Post('switch')
  // switch(dto: Switch{{ pascalCase name }}Dto) {
  //   return this.{{ camelCase name }}Service.switch(dto.id, dto.status);
  // }
}
